#include "../ExEngine/engine/engine.h"
#include "../ExEngine/engine/camera.h"
#include "../ExEngine/render/d3d.h"
#include "scene.h"
#include <winerror.h>

void CameraConstraint(MATRIX4X4F* pInOut)
{
	if(pInOut->_M43 < -17)
		pInOut->_M43 = -17;
	else if(pInOut->_M43 > 5)
		pInOut->_M43 = 5;

	if(pInOut->_M42 < 5)
		pInOut->_M42 = 5;
	else if(pInOut->_M42 > 15)
		pInOut->_M42 = 15;
		
}

HRESULT LoadDemo()
{
	if(SHOW_TRAINS)
		if(FAILED(g_train.Create(10)))
			return E_FAIL;

	if(FAILED(lightManager.Create()))
		return E_FAIL;

	CCamera *pCamera = CEngine::GetInstance()->GetCamera();

	CCamera::cameraData data;
	data.m_mouseAccelerate = 1.0f;
	data.m_mouseSpeed = 5.0f;
	data.m_walkSpeed = 300.0f;

	
	pCamera->initalizeCamera(data);
	pCamera->setState(CCamera::CameraState::FREEVIEW);
	pCamera->setPosition(Vector3f(0,10,0));
	pCamera->setUpdateFunc(CameraConstraint);

	CEngine::GetInstance()->GetRenderer()->SetFogParamters(COLOR3F(0.075,0.075,0.075));
	return S_OK;
}
HRESULT ShutdownDemo()
{

	return S_OK;
}
